import { View } from "../../../../mvc/core/View";
import { TCopy } from "../../../../../Message/Db/Tables/TCopy";
import { Cache } from "../../../cache/Cache";
import { DataEvent } from "../../../events/DataEvent";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { GModuleEvent } from "../../../mvc/GModuleEvent";
import { EventName } from "../../../mvc/EventName";
import { EPlayerItemPosType } from "../../../../../Message/Public/EPlayerItemPosType";
import { JumpFloorWindow } from "./JumpFloorWindow";
import { TowerWareHouse } from "./TowerWareHouse";
import { _EPlayerItemPosTypeTower } from "../../../../../EPlayerItemPosType/_EPlayerItemPosTypeTower";
//class TowerCopyView
    
    export  class TowerCopyView extends View
    {
        constructor()
        {
            super();
            return;
        }

        public showJumpFloorWin(arg1: TCopy): void
        {
            this.jumpFloorWindow.show();
            this.jumpFloorWindow.setCopyInfo(arg1);
            return;
        }

        public hideJumpFloorWin(): void
        {
            this.jumpFloorWindow.hide();
            return;
        }

        public showTowerWareHouse(): void
        {
            this.towerWareHouse.show();
            this.updateWareHouseItems();
            return;
        }

        public hideTowerWareHouse(): void
        {
            this.towerWareHouse.hide();
            return;
        }

        public updateWareHouseItems(): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            if (this._towerWareHouse && !this._towerWareHouse.isHide) 
            {
                loc1 = Cache.instance.pack.towerCopy.getAllItems();
                loc2 = [];
                var loc4=0;
                var loc5=loc1;
                for(loc3 of loc5) 
                {
                    if (!loc3) 
                    {
                        continue;
                    }
                    loc2.push(loc3);
                }
                this._towerWareHouse.updateItems(loc2);
            }
            return;
        }

        /* internal  */onGetDelegateItem(arg1: DataEvent): void
        {
            Dispatcher.dispatchEvent(new DataEvent(GModuleEvent.CopyTowerWarehouse_Get, arg1.data));
            return;
        }

        /* internal  */onGetAllDelegateItem(arg1: DataEvent): void
        {
            Dispatcher.dispatchEvent(new DataEvent(GModuleEvent.CopyTowerWarehouse_GetAll, arg1.data));
            return;
        }

        /* internal  */onDestroyAllDelegateItem(arg1: DataEvent): void
        {
            Dispatcher.dispatchEvent(new DataEvent(GModuleEvent.CopyTowerWarehouse_destroyAll));
            return;
        }

        /* internal  */onFeedAllDelegateItem(arg1: DataEvent): void
        {
            Dispatcher.dispatchEvent(new DataEvent(GModuleEvent.CopyTowerWarehouse_feedAll, arg1.data));
            return;
        }

        /* internal  */onFeedSuitSkill(arg1: DataEvent): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.SuitSkillAddQi, {"posType": _EPlayerItemPosTypeTower, "items": arg1.data}));
            return;
        }

        public get jumpFloorWindow(): JumpFloorWindow
        {
            if (!this._jumpFloorWindow) 
            {
                this._jumpFloorWindow = new JumpFloorWindow();
            }
            return this._jumpFloorWindow;
        }

        public get towerWareHouse(): TowerWareHouse
        {
            if (!this._towerWareHouse) 
            {
                this._towerWareHouse = new TowerWareHouse();
                this._towerWareHouse.addEventListener(GModuleEvent.DelegateWarehouse_Get, this.onGetDelegateItem);
                this._towerWareHouse.addEventListener(GModuleEvent.DelegateWarehouse_GetAll, this.onGetAllDelegateItem);
                this._towerWareHouse.addEventListener(GModuleEvent.DelegateWarehouse_destroyAll, this.onDestroyAllDelegateItem);
                this._towerWareHouse.addEventListener(GModuleEvent.DelegateWarehouse_FeedMount, this.onFeedAllDelegateItem);
                this._towerWareHouse.addEventListener(GModuleEvent.DelegateWarehouse_FeedSuitSkill, this.onFeedSuitSkill);
            }
            return this._towerWareHouse;
        }

        /* internal */ /* var */_jumpFloorWindow: JumpFloorWindow;

        /* internal */ /* var */_towerWareHouse: TowerWareHouse;
    }
